<template>
    <div style="margin:20px;">

     
<div class="title-container">
  <h3 class="title">用户信息</h3>

<!-- <el-row>
        <el-col :span="4" align="right"> -->
          <el-button type="primary" round icon="el-icon-search">搜索</el-button>
          <el-button @click="logout" style="float: right;"  type="danger" round>登出</el-button>
          <div style="text-align: center;">
 </div>

        <!-- </el-col>
      </el-row> -->
    </div>
    <!-- 结果列表 -->
    <el-card>
      <el-table :data="userList" style="width: 100%">
        <el-table-column  label="#" width="100">
            <template slot-scope="scope">
            {{(searchModel.pageNo-1)*searchModel.pageSize+scope.$index+1}}
            </template>
        </el-table-column>
        <el-table-column prop="id" label="用户ID" width="150px"></el-table-column>
        <el-table-column prop="username" label="用户名" width="200px"></el-table-column>
        <el-table-column prop="phone" label="手机号码" width="300px"></el-table-column>
        <el-table-column prop="email" label="电子邮箱" width="400px"></el-table-column>
        <el-table-column prop="status" label="人员状态" width="150px" >
         <template slot-scope="scope">   <el-tag
                     :type="scope.row.status === true ? '' : 'danger'"
                     close-transition>{{scope.row.status?'正常':'注销'}}</el-tag>
         </template>
        </el-table-column>
      </el-table>
    </el-card>
    <!-- 分页组件 -->
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="searchModel.pageNo"
      :page-sizes="[5,10, 20, 50]"
      :page-size="searchModel.pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total">
    </el-pagination>
  </div>
      </template>
    </el-table-column>


  </el-table>
</template>

<script>
 export default {
   data(){
     return {
    
      total: 0,
      searchModel: {
        pageNo: 1,
        pageSize: 10,
      },
       userList:[],
     }
   },
  
   methods:{

     logout(){   
      
         this.$router.replace('/')


       },

     handleSizeChange(pageSize){
      this.searchModel.pageSize = pageSize;
      this.getUserList();
     },

     handleCurrentChange(pageNo){
      this.searchModel.pageNo = pageNo;
      this.getUserList();
     },
    
    getUserList() {
        const data = {
          params: {
          pageNo: this.searchModel.pageNo, 
          pageSize: this.searchModel.pageSize,
          username: this.searchModel.username,
          phone: this.searchModel.phone,
          }
        }
          this.$http.get('/user/list',data).then(res => {
          this.tableDataTemp = res.data.data;
          this.total = this.tableDataTemp.total;
          this.userList = this.tableDataTemp.rows;
        })
      },
      // Search(){
      //   this.searchModel.pageNo = 1;
      //   this.searchModel.username = this.usernameinput.trim(),
      //   this.searchModel.phone = this.phoneinput.trim(),
      //   this.handleLoding();
      // },
      
   },
    mounted() {
      //生命周期 mounted就执行 倒计时函数
    this.getUserList();
  },
  }
 
 </script>




<style>
#search .el-input {
  width: 200px;
  margin-right: 10px;
}
</style>
<style>

.title-container {
  position: relative;
}
.title {
  font-size: 30px;
  color: #bc0e0edd;
  margin: 0px auto 20px auto;
  text-align: center;
  font-weight: bold;
}
</style>
